{% extends "base_generic.html" %}
{% load widget_tweaks %}
{% block content %}
<div class="row justify-content-center mt-5">
  <div class="col-md-6">
    <div class="card shadow-sm">
      <div class="card-body">
        <h2 class="card-title text-center mb-4">🔐 Login</h2>

        {% if form.errors %}
          <div class="alert alert-danger">
            <strong>Oops!</strong> Your username and password didn't match. Please try again.
          </div>
        {% endif %}

        {% if next %}
          {% if user.is_authenticated %}
            <div class="alert alert-warning">
              Your account doesn't have access to this page. Please login with an account that has access.
            </div>
          {% else %}
            <div class="alert alert-info">
              Please login to see this page.
            </div>
          {% endif %}
        {% endif %}

        <form method="post" action="{% url 'login' %}">
          {% csrf_token %}

          <div class="mb-3">
            {{ form.username.label_tag }}
            {{ form.username|add_class:"form-control" }}
          </div>

          <div class="mb-3">
            {{ form.password.label_tag }}
            {{ form.password|add_class:"form-control" }}
          </div>

          <input type="hidden" name="next" value="{{ next }}">

          <div class="d-grid">
            <button type="submit" class="btn btn-primary">Login</button>
          </div>
        </form>

        <hr>
        <p class="text-center">
          <a href="{% url 'password_reset' %}">Forgot your password?</a>
        </p>
      </div>
    </div>
  </div>
</div>
{% endblock %}
